package model.entity;

import model.ability.MapAbility;
import java.util.ArrayList;
import utility.DelayTimer;

public class MapAbilityList {

    private Entity e;
    private DelayTimer timer = new DelayTimer();
    private ArrayList<MapAbility> abilities = new ArrayList<MapAbility>();
    int currentIndex = 0;

    public MapAbilityList(Entity e) {
        this.e = e;
    }

    public void activate() {
        if (!timer.isDelayed()) {
            abilities.get(currentIndex).useMapAbility(e);
        }
    }

    public void next() {
        currentIndex = (currentIndex + 1) % (abilities.size());
    }

    public void prev() {
        if (--currentIndex == -1) {
            currentIndex = abilities.size() - 2;
        }
    }

    public void add(MapAbility ability) {
        abilities.add(ability);
    }

    public void remove(MapAbility ability) {
        abilities.remove(ability);
    }

    public void disable(int delay) {
        timer.delay(delay);
    }

    public void update() {
        timer.update();
    }
}
